package com.sell.sell.service.impl;

import com.sell.sell.dto.OrderDTO;
import com.sell.sell.entity.OrderDetail;
import com.sell.sell.entity.ProductInfo;
import com.sell.sell.service.OrderService;
import com.sell.sell.service.ProductInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 描述:
 * ${DESCRIPTION}
 *
 * @author hzp
 * @create 2018-10-11 17:21
 */
@Service
public class OrderServiceImpl implements OrderService {

    private ProductInfoService productInfoService;

    @Override
    @Transactional
    public OrderDTO createOrder(OrderDTO orderDTO) {

        //获取商品
        for (OrderDetail orderDetail : orderDTO.getOrderDetails() ){
            ProductInfo productInfo=new ProductInfo();
            productInfo=productInfoService.findOne(orderDetail.getProductId());

            //验证库存

            //就算价格

            //订单详情入表
        }

        //订单主表数据入库

        //扣库存



        return null;
    }
}
